﻿using System;
using System.Drawing;
using RRRSRoguelike.Helpers.Visualizer;

namespace RRRSRoguelike.Screens
{
	/// <summary>
	/// Manages the UI to prompt user for high score service.
	/// </summary>
	class HighScoreScreen : Screen
	{
		HighScoreService.HighScoreService hs = new HighScoreService.HighScoreService();

		public HighScoreScreen()
		{
			PanelList.Add(new Panel(new Point(4, 3),
					Visualizer.GetScreenWidth() - 9, Visualizer.GetScreenHeight() - 6));
		}

		public override void Show()
		{
			Clear();



			foreach (Panel p in PanelList)
			{
				p.Clear();
				p.Draw();
			}

			//prompt user
			PanelList[0].Write(Properties.Strings.HighScore + Properties.Strings.YNQuestion);

			bool submitScore;
			ConsoleKey answer;

			//read keyboard
			answer = Console.ReadKey(true).Key;

			//is y pressed?
			submitScore = answer == ConsoleKey.Y;

			//if y is pressed submit high score
			if (submitScore)
			{
				//temp placeholder for unique ID to so only game can update webservice
				string guid = "8f41735e-0048-4e87-be1e-8b923f98aa53";

				//Temp place holder for score, need to set this to actual score value
				int ScorePlaceHolder = 9999;
				PanelList[0].Clear();
				PanelList[0].Write("Score: " + ScorePlaceHolder + ". What is your Name?");

				string name = Console.ReadLine();
				hs.SetHighScores(guid, name, ScorePlaceHolder);
			}
		}

		void Draw()
		{
			Clear();
			PanelList[0].Draw();
		}
	}
}
